#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
class Solution1 {
public:
    int myAtoi(string str) {
        int i = 0, x = 1, sum = 0;
        while (str[i] == ' ')
            i++;
        if (str[i] == '-')
            x = -1;
        if (str[i] == '-' || str[i] == '+')
            i++;
        while (i < str.size() && (str[i] >= '0' && str[i] <= '9')) {
            if (sum > INT_MAX / 10 || (sum == INT_MAX / 10 && str[i] - '0' > 7))
            {
                return x == 1 ? INT_MAX : INT_MIN;
            }
            sum = sum * 10 + (str[i++] - '0');
        }
        return sum * x;
    }
};
class Solution2 {
public:
    string addStrings(string num1, string num2) {
        int b = 0, c = 0, d = num1.size() - 1, e = num2.size() - 1;
        string num;
        while (d >= 0 || e >= 0) {
            int x = d >= 0 ? num1[d--] - '0' : 0;
            int y = e >= 0 ? num2[e--] - '0' : 0;
            c = x + y + b;
            b = c / 10;
            c %= 10;
            num.insert(num.begin(), (c + '0'));
        }
        if (b == 1)
            num.insert(num.begin(), '1');
        return num;
    }
};
class Solution3 {
public:
    string reverseStr(string s, int k) {
        int n = s.length();
        for (int i = 0; i < n; i += 2 * k) {
            reverse(s.begin() + i, s.begin() + min(i + k, n));
        }
        return s;
    }
};

int main() {
    Solution1 a;
    int b = a.myAtoi("2147483646");
    Solution3 c;
    string x = c.reverseStr("abcdefg",2);
}